package dobest.ray.com.jiongjiong.activity.HomePage.trend;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import dobest.ray.com.jiongjiong.R;
import dobest.ray.com.jiongjiong.activity.BaseActivity;
import dobest.ray.com.jiongjiong.views.ChangeCurve.ChangeCurveView;
import dobest.ray.com.jiongjiong.views.NavigationBar;

/**
 * Created by Ray on 2016/4/2.
 * https://github.com/ray0807
 * 用眼负荷承受度
 */
public class EyeLoadToleranceActivity extends BaseActivity implements View.OnClickListener {
    private ChangeCurveView ccv_data_curve;
    private ImageView iv_btn_up;
    private ImageView iv_btn_down;
    private TextView tv_count;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_eye_load_tolerance);
        findViews();
        init();
        addListeners();
    }

    @Override
    public void findViews() {
        navi = (NavigationBar) findViewById(R.id.navi);
        navi.setTitle("用眼负荷承受度");
        navi.setBackListener(R.mipmap.img_back, "");
        ccv_data_curve = (ChangeCurveView) findViewById(R.id.ccv_data_curve);
        iv_btn_up = (ImageView) findViewById(R.id.iv_btn_up);
        iv_btn_down = (ImageView) findViewById(R.id.iv_btn_down);
        tv_count = (TextView) findViewById(R.id.tv_count);

    }

    @Override
    public void init() {
        List<Integer> data = new ArrayList<>();
        data.add(0);
        data.add(1);
        data.add(3);
        data.add(4);
        data.add(6);
        data.add(7);
        data.add(8);
        data.add(10);
        data.add(11);
        data.add(10);
        data.add(8);
        data.add(7);
        data.add(8);
        data.add(6);
        data.add(4);
        data.add(3);
        ccv_data_curve.setData(data);
    }

    @Override
    public void addListeners() {
        iv_btn_down.setOnClickListener(this);
        iv_btn_up.setOnClickListener(this);

    }

    private int count = 0;

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_btn_down:
                if (count > 0) {
                    count--;
                }
                tv_count.setText("" + count);
                break;
            case R.id.iv_btn_up:
                count++;
                tv_count.setText("" + count);
                break;
        }
    }
}
